﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板

namespace 二年级上实验周课题1
{
    /// <summary>
    /// 可用于自身或导航至 Frame 内部的空白页。
    /// </summary>


    public sealed partial class 支付页面 : Page
    {
        int fare;//车票价格
        int pay;//已付
        int dib;//零钱
        int Number_of_Station;//车站数
        public 支付页面()
        {
            this.InitializeComponent();            
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter != null && e.Parameter is string)
            {
                string DATAVALUE = e.Parameter as string;
                
                string[] sArray = DATAVALUE.Split('_');
                终点.Text = sArray[0];
                Ticket.Text = sArray[1];
            }
        }
        private void MONEY_Click(object sender, RoutedEventArgs e)
        {
            string money = (e.OriginalSource as UIElement).GetValue(NameProperty).ToString();
            pay += (Convert.ToInt32(money.Substring(1)));
            Pay.Text = pay.ToString();
            dib = pay - Convert.ToInt32(Fare.Text.ToString());
            if(dib>0)
            {
                Dib.Text = dib.ToString();
            }
            else
            {
                Dib.Text = "0";
            }
        }
        private void 终点_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
        {
            NumTicke();
            Fare.Text = (Convert.ToInt32(Ticket.Text.ToString()) * fare).ToString();
        }
        private async void 确认_Click(object sender, RoutedEventArgs e)
        {
            if (pay>0)
            {
                if (dib < 0)
                {
                    MessageDialog msg1 = new MessageDialog("投币不足，请继续投币！");
                    await msg1.ShowAsync();
                }
                else if (dib > 0)
                {
                    MessageDialog msg = new MessageDialog("\t\t信息\n始发站：\n\t仙林中心\n终点站：\n\t" + 终点.Text.ToString() + "\n票数\n\t" + Ticket.Text.ToString() + "\n找零：\n\t" + Dib.Text.ToString() + "元\n\n\n\t南京地铁祝您路途愉快！");
                    await msg.ShowAsync();
                    Frame.Navigate(typeof(MainPage));
                }
                else if (dib == 0)
                {
                    MessageDialog msg = new MessageDialog("\t\t信息\n始发站：\n\t仙林中心\n终点站：\n\t" + 终点.Text.ToString() + "\n票数\n\t" + Ticket.Text.ToString() + "\n\n\n\t南京地铁祝您路途愉快！");
                    await msg.ShowAsync();
                    Frame.Navigate(typeof(MainPage));
                }
            }
            else
            {
                MessageDialog msg1 = new MessageDialog("投币不足，请继续投币！");
                await msg1.ShowAsync();
            }

        }
        private void 返回_Click(object sender, RoutedEventArgs e)
        {
            Frame.GoBack();
        }
        public void Colculatefare(int x)
        {
            if (x >= 0 && x < 6)
            {
                fare = 2;
            }
            else if (x >= 6 && x < 10)
            {
                fare = 3;
            }
            else if (x >= 10 && x < 15)
            {
                fare = 4;
            }
            else if (x >= 15 && x < 20)
            {
                fare = 5;
            }
            else if (x >= 20 && x < 25)
            {
                fare = 6;
            }
            else if (x >= 25 && x < 30)
            {
                fare = 7;
            }
            else if (x > 30)
            {
                fare = 8;
            }
        }   //计算票价
        public void NumTicke()
        {
            if (终点.Text.ToString() == "迈皋桥")
            {
                Number_of_Station = 19;
                Colculatefare(Number_of_Station);
                return;
            }
            if (终点.Text.ToString() == "红山动物园")
            {
                Number_of_Station = 18;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "新模范马路")
            {
                Number_of_Station = 16;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "玄武门")
            {
                Number_of_Station = 15;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "鼓楼")
            {
                Number_of_Station = 14;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "珠江路")
            {
                Number_of_Station = 13;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "新街口")
            {
                Number_of_Station = 12;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "张府园")
            {
                Number_of_Station = 13;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "三山街")
            {
                Number_of_Station = 14;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "中华门")
            {
                Number_of_Station = 15;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "天龙寺")
            {
                Number_of_Station = 17;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "软件大道")
            {
                Number_of_Station = 18;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "花神庙")
            {
                Number_of_Station = 19;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "双龙大道")
            {
                Number_of_Station = 21;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "河定桥")
            {
                Number_of_Station = 22;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "胜太路")
            {
                Number_of_Station = 23;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "百家湖")
            {
                Number_of_Station = 24;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "小龙湾")
            {
                Number_of_Station = 25;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "竹山路")
            {
                Number_of_Station = 26;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "天印大道")
            {
                Number_of_Station = 27;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "龙眠大道")
            {
                Number_of_Station = 28;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "南医大江苏经贸学院")
            {
                Number_of_Station = 29;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "南京交院")
            {
                Number_of_Station = 30;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "中国药科大学")
            {
                Number_of_Station = 31;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "油坊桥")
            {
                Number_of_Station = 22;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "雨润大街")
            {
                Number_of_Station = 21;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "元通")
            {
                Number_of_Station = 20;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "奥体东站")
            {
                Number_of_Station = 19;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "兴隆大街")
            {
                Number_of_Station = 18;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "集庆门大街")
            {
                Number_of_Station = 17;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "云锦路")
            {
                Number_of_Station = 16;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "莫愁湖")
            {
                Number_of_Station = 15;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "汉中门")
            {
                Number_of_Station = 14;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "上海路")
            {
                Number_of_Station = 13;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "西安门")
            {
                Number_of_Station = 10;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "明故宫")
            {
                Number_of_Station = 9;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "苜蓿园")
            {
                Number_of_Station = 8;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "下马坊")
            {
                Number_of_Station = 7;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "孝陵卫")
            {
                Number_of_Station = 6;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "钟灵街")
            {
                Number_of_Station = 5;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "马群")
            {
                Number_of_Station = 4;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "金马路")
            {
                Number_of_Station = 3;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "仙鹤门")
            {
                Number_of_Station = 2;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "学则路")
            {
                Number_of_Station = 1;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "仙林中心")
            {
                Number_of_Station = 0;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "羊山公园")
            {
                Number_of_Station = 1;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "南大仙林校区")
            {
                Number_of_Station = 2;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "经天路")
            {
                Number_of_Station = 3;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "林场")
            {
                Number_of_Station = 24;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "星火路")
            {
                Number_of_Station = 23;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "东大成贤学院站")
            {
                Number_of_Station = 22;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "泰冯路")
            {
                Number_of_Station = 21;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "天润城")
            {
                Number_of_Station = 20;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "柳州东路")
            {
                Number_of_Station = 19;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "上元门")
            {
                Number_of_Station = 18;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "五塘广场")
            {
                Number_of_Station = 17;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "小市")
            {
                Number_of_Station = 16;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "南京站")
            {
                Number_of_Station = 15;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "南京林业大学新庄")
            {
                Number_of_Station = 14;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "鸡鸣寺")
            {
                Number_of_Station = 13;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "浮桥")
            {
                Number_of_Station = 12;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "大行宫")
            {
                Number_of_Station = 11;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "常府街")
            {
                Number_of_Station = 12;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "夫子庙")
            {
                Number_of_Station = 13;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "武定门")
            {
                Number_of_Station = 14;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "雨花门")
            {
                Number_of_Station = 15;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "卡子门")
            {
                Number_of_Station = 16;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "大明路")
            {
                Number_of_Station = 17;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "明城大道")
            {
                Number_of_Station = 18;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "南京南站")
            {
                Number_of_Station = 19;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "宏运大道")
            {
                Number_of_Station = 20;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "胜太西路")
            {
                Number_of_Station = 21;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "天元西路")
            {
                Number_of_Station = 22;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "九龙湖")
            {
                Number_of_Station = 23;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "诚信大道")
            {
                Number_of_Station = 24;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "东大九龙湖校区")
            {
                Number_of_Station = 25;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "秣周东路")
            {
                Number_of_Station = 26;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "龙江站")
            {
                Number_of_Station = 14;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "草场门站")
            {
                Number_of_Station = 13;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "云南路站")
            {
                Number_of_Station = 12;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "九华山站")
            {
                Number_of_Station = 9;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "岗子村站")
            {
                Number_of_Station = 8;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "蒋王庙站")
            {
                Number_of_Station = 7;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "王家湾站")
            {
                Number_of_Station = 6;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "聚宝山站")
            {
                Number_of_Station = 5;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "徐庄站")
            {
                Number_of_Station = 4;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "汇通路站")
            {
                Number_of_Station = 4;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "灵山站")
            {
                Number_of_Station = 5;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "东流站")
            {
                Number_of_Station = 6;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "孟北站")
            {
                Number_of_Station = 7;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "桦墅站")
            {
                Number_of_Station = 8;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "仙林湖站")
            {
                Number_of_Station = 9;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "禄口机场")
            {
                Number_of_Station = 27;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "翔宇路南")
            {
                Number_of_Station = 26;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "翔宇路北")
            {
                Number_of_Station = 25;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "正方中路")
            {
                Number_of_Station = 24;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "吉印大道")
            {
                Number_of_Station = 23;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "河海大学·佛城西路")
            {
                Number_of_Station = 22;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "翠屏山")
            {
                Number_of_Station = 21;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "泰山新村")
            {
                Number_of_Station = 22;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "高新开发区")
            {
                Number_of_Station = 22;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "信息工程大学")
            {
                Number_of_Station = 23;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "卸甲甸")
            {
                Number_of_Station = 24;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "大厂")
            {
                Number_of_Station = 25;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "葛塘")
            {
                Number_of_Station = 26;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "长芦")
            {
                Number_of_Station = 27;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "化工园")
            {
                Number_of_Station = 28;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "六合开发区")
            {
                Number_of_Station = 29;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "龙池")
            {
                Number_of_Station = 30;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "雄州")
            {
                Number_of_Station = 31;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "凤凰山公园")
            {
                Number_of_Station = 32;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "方州广场")
            {
                Number_of_Station = 33;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "沈桥")
            {
                Number_of_Station = 34;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "八百桥")
            {
                Number_of_Station = 35;
                Colculatefare(Number_of_Station);                 
                return;
            }
            if (终点.Text.ToString() == "金牛湖")
            {
                Number_of_Station = 36;
                Colculatefare(Number_of_Station);
                return;
            }
            if (终点.Text.ToString() == "安德门")
            {
                Number_of_Station = 23;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "小行")
            {
                Number_of_Station = 22;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "中胜")
            {
                Number_of_Station = 21;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "奥体中心")
            {
                Number_of_Station = 21;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "梦都大街")
            {
                Number_of_Station = 22;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "绿博园")
            {
                Number_of_Station = 23;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "江心洲")
            {
                Number_of_Station = 24;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "临江站")
            {
                Number_of_Station = 25;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "浦口万汇城")
            {
                Number_of_Station = 26;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "南京工业大学")
            {
                Number_of_Station = 27;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "龙华路")
            {
                Number_of_Station = 28;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "文德路")
            {
                Number_of_Station = 29;
                Colculatefare(Number_of_Station);
                 
                return;
            }
            if (终点.Text.ToString() == "雨山路")
            {
                Number_of_Station = 30;
                Colculatefare(Number_of_Station);
                 
                return;
            }
        }//计算车站数
    }
}
